package com.hospital.hospitalserver.mapper;

import com.hospital.hospitalserver.entity.ScheduleDataRequest;
import com.hospital.hospitalserver.entity.ScheduleInstanceDTO;
import com.hospital.hospitalserver.entity.Vo.DoctorSchedule;
import com.hospital.hospitalserver.entity.Vo.ScheduleInstance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Set;

/**
 * 排班实例接口方法
 * */
@Mapper
public interface ScheduleInstanceMapper {
    /**
     * 排班实例添加功能
     * */
    Integer addScheduleInstances(ScheduleInstanceDTO scheduleInstance);

    /**
     * 排班实例修改功能 ???
     * */
    Integer updateScheduleInstances(ScheduleInstanceDTO scheduleInstance);

    /**
     * 删除指定人员和日期范围的排班
     * */
    Integer deleteByStaffAndDateRange(@Param("staffIds") Set<Integer> staffIds,
                                      @Param("startDate") LocalDate startDate,
                                      @Param("endDate") LocalDate endDate);

    /**
     * 排班实例删除功能
     * */
    Integer deleteScheduleInstances(ScheduleInstanceDTO instance);

    /**
     * 检查排班实例是否存在
     * 检查参数staff_id,schedule_date,time_slot_code,schedule_type
     * */
    Integer checkExists(ScheduleInstanceDTO instance);

    /**
     * 查找已存在的排班
     */
    ScheduleInstanceDTO findExistingSchedule(ScheduleInstanceDTO instance);

    /**
     * 根据查询条件加载排班实例数据-月视图-周视图-日视图
     * */
    List<ScheduleInstance> getScheduleInstancesDataBySearch(ScheduleDataRequest request);

    /**
     * 获取今天已排班的科室和医生信息
     * 用于挂号
     * */
    List<ScheduleInstance> getScheduleInstancesDataByCurrentDate();

    /**
     *  根据instance_id查询排班实例数据
     * */
    ScheduleInstance getScheduleInstanceDataByScheduleId(@Param("instance_id") Integer instance_id);

    /**
     * 根据科室ID和日期查询医生排班信息
     * */
    List<DoctorSchedule> selectDoctorByDepartmentAndDate(
            @Param("department_id") Integer departmentId,
            @Param("schedule_date") String scheduleDate,
            @Param("schedule_type") String scheduleType
    );

    /**
     * 根据医生ID查询医生详细信息
     */
    DoctorSchedule selectDoctorDetailById(@Param("doctor_id") Integer doctorId);
}
